/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ceair.flight.refund.service.cronjob.autocheck.impl;

import com.ceair.flight.refund.dto.appmoblie.RefundApplyDto;
import com.ceair.flight.refund.service.cronjob.autocheck.IAutoChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author youguilin
 */
public abstract class AbstractAutoChecker implements IAutoChecker {

    private static final Logger LOG = LoggerFactory.getLogger(AbstractAutoChecker.class);
    private IAutoChecker nextChecker;
    private final String checkerName;

    public AbstractAutoChecker(String checkerName) {
        this.checkerName = checkerName;
    }

    @Override
    public void setNextChecker(IAutoChecker nextChecker) {
        LOG.info("Auto auditable checker {} set next checker to {}", checkerName, ((AbstractAutoChecker) nextChecker).getCheckerName());
        this.nextChecker = nextChecker;
    }

    protected boolean goNextOrReturn(RefundApplyDto refundApply) {
        return getNextChecker() != null ? getNextChecker().autoCheck(refundApply) : false;
    }

    public IAutoChecker getNextChecker() {
        return nextChecker;
    }

    public String getCheckerName() {
        return checkerName;
    }

}
